#coding=utf-8

import db
import spider
import time

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

while 1:

    container = spider.Container()
    
    count=0
    for i in spider.zhanqiParser().parse():
        count+=1
        container.append(i)
    print u'战旗爬取完毕，获得{}条直播数据'.format(count)
    
    count=0
    for i in spider.xiongmaoParser().parse():
        count+=1
        container.append(i)
    print u'熊猫爬去完毕,获得{}条直播数据'.format(count)

    count=0
    for i in spider.douyuParser().parse():
        count+=1
        container.append(i)
    print u'斗鱼爬取完毕,获得{}条直播数据'.format(count)

    db.db.insert_or_update(container)
    print u'15分钟后重新启动爬虫'
    
    time.sleep(15*60)
